package org.example.Server.controller.resource;


import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.resource.ResourceDTO;
import org.example.Server.service.resource.ResourceService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 教师端个人中心资源
 */
@RestController
@Slf4j
@RequestMapping("/youxich/resource/personal")
public class ResourcePersonalController {
    @Autowired
    ResourceService resourceService;
    /**
     * 获取非审核类型的教师资源
     * @return
     */
    @GetMapping
    public ResultAPI getlist(@RequestParam Integer tech_id, @RequestParam String resource_type) {
        return resourceService.getRePersonList(tech_id,resource_type);
    }

    /**
     * 添加非审核类型资源
     * @param resourceDTO
     * @param file
     * @return
     */
    @PostMapping
    public ResultAPI addResource(ResourceDTO resourceDTO,MultipartFile file) {
        return resourceService.addResource(resourceDTO,file);
    }

    /**
     * 修改教师非审核资源
     * @param resourceDTO
     * @return
     */
    @PutMapping
    public ResultAPI updateResource(@RequestBody ResourceDTO resourceDTO) {
        return resourceService.updateResource(resourceDTO);
    }

    /**
     * 删除教师非审核资源
     * @param resource_id
     * @return
     */
    @DeleteMapping("{resource_id}")
    public ResultAPI deleteResource(@PathVariable Integer resource_id) {
        return resourceService.deleteResource(resource_id);
    }
}
